# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>
# Contributor: Aram Drevekenin <aram@poor.dev>

pkgname=bandwhich
pkgver=0.21.1
pkgrel=1
pkgdesc='Terminal bandwidth utilization tool'
url='https://github.com/imsnif/bandwhich'
arch=('loong64' 'x86_64')
license=('MIT')
depends=('gcc-libs')
makedepends=('cargo')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/imsnif/${pkgname}/archive/refs/tags/v${pkgver}.tar.gz)
sha512sums=('4bd48c598e643c5541884fab5df8534138078820833c3248dcf778616b1149fa074e43a8448e8dc92bc8d06f5e76baa8df9e7f4f2c5eccd21ab15190e17b0cf2')
b2sums=('93467029a003356786e3a49d00062ee42b9a3f0f805bb42dbe0c37aed24303c1d7ac3907ed064af29584e3311d217c70c4027f6e35e20f68ce0292052b23b83b')

prepare() {
  cd "${pkgname}-${pkgver}"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "${pkgname}-${pkgver}"
  cargo build --release --frozen
}

check() {
  cd "${pkgname}-${pkgver}"
  cargo test --release --frozen -- --skip layout_under_50_width_under_50_height
}

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm 755 "target/release/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
  install -Dm 644 "docs/bandwhich.1" -t "${pkgdir}/usr/share/man/man1"
  install -Dm 644 LICENSE.md "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

# vim: ts=2 sw=2 et:
